package library;

import java.util.Set;
import java.util.TreeSet;

class Movie 
	extends Item
{
	private String title;
	private String director;
	private int nScenes;
	private Set<String> keywords;
	private Set<String> casts;
	
	public Movie(String title, String director, int nScenes, String... keywords){
		this.title = title;
		this.director = director;
		this.nScenes = nScenes;
		this.keywords = new TreeSet<String>();
		this.keywords.clear();
		for(String s: keywords){
			this.keywords.add(s);
		}
	}
	
	public String getTitle(){
		return this.title;
	}
	
	public String getCreator() {
		return this.director;
	}

	public Set<String> getGroup() {
		return this.casts;
	}

	@Override
	public Set<String> getKeyword() {
		return this.keywords;
	}
	
	public String toString(){
		String result;
		result = "-Movie-\r\n";
		result += "director: " + this.director + "\r\n# scenes: " + this.nScenes;
		
		result += "\r\ncast:     ";
		boolean flag = false;
		for(String s: casts){
			if (flag == false){
				result += s;
				flag = true;
			}
			else{
				result += ", " + s;
			}
		}
		
		result += "\r\ntitle:    " + this.title + "\r\nkeywords: ";
		
		flag = false;
		for(String s: keywords){
			if (flag == false){
				result += s;
				flag = true;
			}
			else{
				result += ", " + s;
			}
		}
		result += "\r\n";
		return result;
	}

	public void add(String... M) {
		this.casts = new TreeSet<String>();
		this.casts.clear();
		for(String m: M){
			this.casts.add(m);
		}
	}

	

}
